<template>
    <div style="width: 100%;height: 100%;position: relative;background-color: red;">

    </div>
    <div v-if="errorPage.show != 0"
        style="width: 100%;height: 100%;position: relative;align-items: center;display: flex;position: absolute;left: 0;top: 0;text-align: center;justify-content: center;background-color: #fff;transition: opacity .3s cubic-bezier(0.23, 1, 0.320, 1);padding-left: 40px;padding-right: 40px;font-size: 24px;"
        :style="{
            opacity: errorPage.show == 2 ? 1 : 0,
        }">
        {{ errorPage.text }}
    </div>
</template>

<script>
import { api } from 'src/boot/axios';


export default {
    data() {
        return {
            ppr: 1,
            data: [],
            status: 0,
            errorPage: {
                show: 0,
                text: ''
            }
        };
    },
    watch: {
        'width'() {
            let e = this.$props.width - 4
            this.ppr = e / 750
        },
    },
    methods: {
        waitSeconds(n) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve()
                }, n * 1000);
            })
        },
        loadedData() {
            this.$emit('loadedData')
        },
        async controlErrorPage(op, text = '') {
            if (op) {
                this.errorPage.text = text
                this.errorPage.show = 1
                await this.waitSeconds(0.3)
                this.errorPage.show = 2
            } else {
                this.errorPage.show = 1
                await this.waitSeconds(0.3)
                this.errorPage.show = 0
            }
        },
        async processInComData() {
            const qs = require('qs')
            let data = JSON.parse(JSON.stringify(this.incomData))
            if (data.length == 0) {
                this.controlErrorPage(true, '没有数据')
                this.loadedData()
                return
            }
            for (let i = 0; i < data.length; i++) {
                data[i] = data[i].slice(data[i].indexOf('?') + 1)
                data[i] = qs.parse(data[i])
            }
            data = JSON.parse(JSON.stringify(data))
            console.log(data)
            for (let i = 0; i < data.length; i++) {
                delete data[i].typeName
            }
            let res = []
            for (let i = 0; i < data.length; i++) {
                let re = await api.get(process.env.api + '/transaction/sub/getEntityTable2?' + qs.stringify(data[i]))
                console.log(re.data)
                if(re.data.status=='SUCCESS'){
                    let re1 = await api.post(process.env.api + '/route/route/getPropertyConversion', re.data)
                    if(re1.data.status=='SUCCESS'){
                        re.data.data = re1.data.data
                        res.push(re.data)
                    }else{
                        continue
                    }
                }else{
                    continue
                }
            }
            this.data = res
            console.log(res)
            this.loadedData()
        }
    },
    mounted() {
        this.$emit('startLoad')
        this.processInComData()
    },
    props: {
        incomData: {
            type: Array,
            default: []
        },
        width: {
            type: Number,
            default: 0
        }
    }
};
</script>

<style></style>